﻿<UserControl x:Class="YATE.TextBoxWatermark"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             x:Name="UC"
             d:DesignWidth="600"
             mc:Ignorable="d">
    <Grid>
        <TextBox x:Name="SearchTermTextBox"
                 Margin="5"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Center"
                 BorderThickness="0"
                 KeyDown="SearchTermTextBox_KeyDown"
                 TextChanged="SearchTermTextBox_TextChanged" />
        <TextBlock x:Name="tx_Watermark"
                   Margin="10,0,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Center"
                   Foreground="DarkGray"
                   IsHitTestVisible="False"
                   Text="{Binding ElementName=UC,
                                  Mode=OneWay,
                                  Path=Watermark}">
            <TextBlock.Style>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Text, ElementName=SearchTermTextBox}" Value="">
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>
        </TextBlock>
    </Grid>
</UserControl>
